# -*-coding = utf-8 -*-

# @Time: 2021/4/10 0:09
# @Author: bistro
# @File: p263.py
# @Software: PyCharm
class Solution:
    def isUgly(self, n: int) -> bool:
        if n == 1 or n == 2 or n == 3 or n == 5:
            return True
        else:
            while n % 2 == 0 or n % 3 == 0 or n % 5 == 0:
                if n % 2 == 0:
                    n = n//2
                elif n % 3 == 0:
                    n = n // 3
                elif n % 5 == 0:
                    n = n // 5
            if n == 1:
                return True
            else:
                return False
